package com.hx.vending.service.impl;

import com.hx.vending.bean.*;
import com.hx.vending.bean.entity.EquipmentTypeEntity;
import com.hx.vending.bean.entity.EquipmentTypeRiseVO;
import com.hx.vending.bean.entity.EquipmentTypeVO;
import com.hx.vending.dao.*;
import com.hx.vending.service.IEquipmentTypeService;
import com.hx.vending.util.Msg;
import com.hx.vending.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/1/12.
 */
@Service
public class EquipmentTypeServiceImpl implements IEquipmentTypeService {

    @Resource
    private EquipmentTypeMapper equipmentTypeMapper;

    @Autowired
    private EquipmentTypeRiseMapper equipmentTypeRiseMapper;


    @Autowired
    private TrailsMapper trailsMapper;

    @Autowired
    private EquipmentMapper equipmentMapper;

    @Autowired
    private EquipmentTypeTrailsMapper equipmentTypeTrailsMapper;

    @Autowired
    private EquipmentTypeCaseMapper equipmentTypeCaseMapper;


    @Override
    public Msg insertTypeAndRise(EquipmentTypeVO equipmentTypeVO) {
        EquipmentTypeCase equipmentTypeCase = new EquipmentTypeCase();
        equipmentTypeCase.setEquipmentCaseName(equipmentTypeVO.getEquipmentCaseName());
        equipmentTypeCase.setEquipmentCaseNumber(equipmentTypeVO.getEquipmentCaseNumber());
        equipmentTypeCase.setEquipmentCaseRemarks(equipmentTypeVO.getEquipmentCaseRemarks());
        equipmentTypeCase.setEquipmentTypeId(equipmentTypeVO.getEquipmentTypeId());
        int result = equipmentTypeMapper.insertEquipmentCase(equipmentTypeCase);
        if(result > 0){
            EquipmentTypeCase typeCase = equipmentTypeMapper.selectCaseByExample(equipmentTypeCase);
            List<EquipmentTypeRise> equipmentTypeRiseList = equipmentTypeVO.getEquipmentTypeRiseList();
            for(int e = 0;e < equipmentTypeRiseList.size();e++){
                int t = e +1;
                if(e < 10){
                    equipmentTypeRiseList.get(e).setEquipmentTypeRise("0"+t);
                }else{
                    equipmentTypeRiseList.get(e).setEquipmentTypeRise(t+"");
                }
                equipmentTypeRiseList.get(e).setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                equipmentTypeRiseList.get(e).setEquipmentTypeId(equipmentTypeVO.getEquipmentTypeId());
            }
            int i = equipmentTypeRiseMapper.insertBatchRise(equipmentTypeRiseList);
            if(i > 0){
                EquipmentTypeRise equipmentTypeRise = new EquipmentTypeRise();
                equipmentTypeRise.setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                List<EquipmentTypeRise> typeRiseList = equipmentTypeRiseMapper.selectByExampleSelective(equipmentTypeRise);
                for(int v = 0;v < typeRiseList.size();v++){
                    if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseTrails()) && typeRiseList.get(v).getEquipmentTypeRiseTrails() != 0){
                        List<EquipmentTypeTrails> equipmentTypeTrailsList = new ArrayList<>();
                        for(int j = 0;j < typeRiseList.get(v).getEquipmentTypeRiseTrails();j++){
                            EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
                            //货道编号
                            int ceng = v+1;
                            int d = j+1;
                            typeTrails.setEquipmentTypeTrailsNumber( ceng+"-"+d);
                            //机柜id
                            typeTrails.setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                            //设备类型id
                            typeTrails.setEquipmentTypeId(equipmentTypeVO.getEquipmentTypeId());
                            //层id
                            typeTrails.setEquipmentTypeTrailsRise(typeRiseList.get(v).getEquipmentTypeRiseId());
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseCapacity()) && typeRiseList.get(v).getEquipmentTypeRiseCapacity() != 0){
                                typeTrails.setEquipmentTypeTrailsCapacity(typeRiseList.get(v).getEquipmentTypeRiseCapacity());
                            }
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseType()) && typeRiseList.get(v).getEquipmentTypeRiseType() != 0){
                                typeTrails.setEquipmentTypeTrailsType(typeRiseList.get(v).getEquipmentTypeRiseType());
                            }
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRise())){
                                String riseNumber = "";
                                if(v < 10){
                                    riseNumber = "0"+ v;
                                }else{
                                    riseNumber =v+"";
                                }
                                if(j < 10){
                                    typeTrails.setEquipmentTypeTrailsPosition(riseNumber+"0"+j);
                                }else{
                                    typeTrails.setEquipmentTypeTrailsPosition(riseNumber+j);
                                }
                            }
                            equipmentTypeTrailsList.add(typeTrails);
                        }
                        int x = equipmentTypeTrailsMapper.insertBatchTrails(equipmentTypeTrailsList);
                    }
                }
                return Msg.success().add("typeCase",typeCase);
            }
        }

        return Msg.fail();
    }

    @Override
    public Msg getEquipmentType(String typeName,Integer pageNum) {
        Integer num = equipmentTypeMapper.selectEquipmentTypeNum(typeName);
        List<EquipmentType> equipmentTypeList = equipmentTypeMapper.getEquipmentTypeBycondition(typeName,pageNum);
        List<EquipmentTypeEntity> equipmentTypeEntities = new ArrayList<>();
        for(EquipmentType equipmentType: equipmentTypeList){
            EquipmentTypeEntity equipmentTypeEntity = new EquipmentTypeEntity();
            equipmentTypeEntity.setEquipmentTypeId(equipmentType.getEquipmentTypeId());
            equipmentTypeEntity.setEquipmentTypeName(equipmentType.getEquipmentTypeName());
            equipmentTypeEntity.setEquipmentTypeNumber(equipmentType.getEquipmentTypeNumber());
            equipmentTypeEntity.setEquipmentTypeRemarks(equipmentType.getEquipmentTypeRemarks());
            equipmentTypeEntity.setEquipmentTypeTime(equipmentType.getEquipmentTypeTime());
            EquipmentTypeCase equipmentTypeCase = new EquipmentTypeCase();
            equipmentTypeCase.setEquipmentTypeId(equipmentType.getEquipmentTypeId());
            List<EquipmentTypeCase> typeCaseList = equipmentTypeCaseMapper.selectByExampleSelective(equipmentTypeCase);
            List<EquipmentTypeVO> equipmentTypeVOList = new ArrayList<>();
            for(EquipmentTypeCase typeCase:typeCaseList){
                EquipmentTypeVO equipmentTypeVO = new EquipmentTypeVO();
                equipmentTypeVO.setEquipmentTypeId(typeCase.getEquipmentTypeId());
                equipmentTypeVO.setEquipmentCaseId(typeCase.getEquipmentCaseId());
                equipmentTypeVO.setEquipmentCaseName(typeCase.getEquipmentCaseName());
                equipmentTypeVO.setEquipmentCaseNumber(typeCase.getEquipmentCaseNumber());
                equipmentTypeVO.setEquipmentCaseRemarks(typeCase.getEquipmentCaseRemarks());
                EquipmentTypeRise equipmentTypeRise = new EquipmentTypeRise();
                equipmentTypeRise.setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                List<EquipmentTypeRise> equipmentTypeRiseList = equipmentTypeRiseMapper.selectByExampleSelective(equipmentTypeRise);
                equipmentTypeVO.setEquipmentTypeRiseList(equipmentTypeRiseList);
                equipmentTypeVOList.add(equipmentTypeVO);
            }
            equipmentTypeEntity.setEquipmentTypeVOList(equipmentTypeVOList);
            equipmentTypeEntities.add(equipmentTypeEntity);
        }
        return Msg.success().add("equipmentTypeList",equipmentTypeEntities).add("num",num);
    }

    @Override
    public Msg getEquipmentTrails(Integer equipmentCaseId) {
        EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
        typeTrails.setEquipmentTypeCaseId(equipmentCaseId);
        Map<String,List<EquipmentTypeTrails>> map = new HashMap<>();
        List<EquipmentTypeTrails> typeTrailsList = equipmentTypeTrailsMapper.selectByExampleSelective(typeTrails);
        for(EquipmentTypeTrails equipmentTypeTrails:typeTrailsList){
            EquipmentTypeRise typeRise = new EquipmentTypeRise();
            typeRise.setEquipmentTypeRiseId(equipmentTypeTrails.getEquipmentTypeTrailsRise());
            EquipmentTypeRise equipmentTypeRise = equipmentTypeRiseMapper.selectByPrimaryKeySelective(typeRise);
            List<EquipmentTypeTrails> equipmentTypeTrailsList = new ArrayList<>();
            if (ToolUtil.isEmpty(map.get(equipmentTypeRise.getEquipmentTypeRise()))){
                equipmentTypeTrailsList.add(equipmentTypeTrails);
                map.put(equipmentTypeRise.getEquipmentTypeRise(),equipmentTypeTrailsList);
            }else{
                equipmentTypeTrailsList = map.get(equipmentTypeRise.getEquipmentTypeRise());
                equipmentTypeTrailsList.add(equipmentTypeTrails);
                map.put(equipmentTypeRise.getEquipmentTypeRise(),equipmentTypeTrailsList);
            }
        }
        return Msg.success().add("equipmentTrails",map);
    }

    @Override
    public Msg editEquipmentType(EquipmentType equipmentType) {
        int i = equipmentTypeMapper.updateByPrimaryKeySelective(equipmentType);
        if (i > 0){
            return Msg.success();
        }
        return Msg.fail();
    }

    @Override
    public Msg editEquipmentTypeCase(EquipmentTypeVO equipmentTypeVO) {
        EquipmentTypeCase equipmentTypeCase = new EquipmentTypeCase();
        equipmentTypeCase.setEquipmentCaseId(equipmentTypeVO.getEquipmentCaseId());
        equipmentTypeCase.setEquipmentCaseNumber(equipmentTypeCase.getEquipmentCaseNumber());
        equipmentTypeCase.setEquipmentCaseName(equipmentTypeVO.getEquipmentCaseName());
        equipmentTypeCase.setEquipmentCaseRemarks(equipmentTypeVO.getEquipmentCaseRemarks());
        equipmentTypeCase.setEquipmentTypeId(equipmentTypeVO.getEquipmentTypeId());
        int result = equipmentTypeCaseMapper.updateByPrimaryKeySelective(equipmentTypeCase);
        if(result > 0){
            EquipmentTypeCase typeCase = equipmentTypeMapper.selectCaseByExample(equipmentTypeCase);
           int r = equipmentTypeRiseMapper.deleteRiseByCaseId(equipmentTypeVO.getEquipmentCaseId());
           int u = equipmentTypeTrailsMapper.deleteTrailsByCaseId(equipmentTypeVO.getEquipmentCaseId());
            List<EquipmentTypeRise> equipmentTypeRiseList = equipmentTypeVO.getEquipmentTypeRiseList();
            for(int e = 0;e < equipmentTypeRiseList.size();e++){
                int t = e +1;
                if(e < 10){
                    equipmentTypeRiseList.get(e).setEquipmentTypeRise("0"+t);
                }else{
                    equipmentTypeRiseList.get(e).setEquipmentTypeRise(t+"");
                }
                equipmentTypeRiseList.get(e).setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                equipmentTypeRiseList.get(e).setEquipmentTypeId(typeCase.getEquipmentTypeId());
            }
            int i = equipmentTypeRiseMapper.insertBatchRise(equipmentTypeRiseList);
            if(i > 0){
                EquipmentTypeRise equipmentTypeRise = new EquipmentTypeRise();
                equipmentTypeRise.setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                List<EquipmentTypeRise> typeRiseList = equipmentTypeRiseMapper.selectByExampleSelective(equipmentTypeRise);
                for(int v = 0;v < typeRiseList.size();v++){
                    if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseTrails()) && typeRiseList.get(v).getEquipmentTypeRiseTrails() != 0){
                        List<EquipmentTypeTrails> equipmentTypeTrailsList = new ArrayList<>();
                        for(int j = 0;j < typeRiseList.get(v).getEquipmentTypeRiseTrails();j++){
                            EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
                            //货道编号
                            int ceng = v+1;
                            int d = j+1;
                            typeTrails.setEquipmentTypeTrailsNumber( ceng+"-"+d);
                            //机柜id
                            typeTrails.setEquipmentTypeCaseId(typeCase.getEquipmentCaseId());
                            //设备类型id
                            typeTrails.setEquipmentTypeId(typeCase.getEquipmentTypeId());
                            //层id
                            typeTrails.setEquipmentTypeTrailsRise(typeRiseList.get(v).getEquipmentTypeRiseId());
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseCapacity()) && typeRiseList.get(v).getEquipmentTypeRiseCapacity() != 0){
                                typeTrails.setEquipmentTypeTrailsCapacity(typeRiseList.get(v).getEquipmentTypeRiseCapacity());
                            }
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRiseType()) && typeRiseList.get(v).getEquipmentTypeRiseType() != 0){
                                typeTrails.setEquipmentTypeTrailsType(typeRiseList.get(v).getEquipmentTypeRiseType());
                            }
                            if(ToolUtil.isNotEmpty(typeRiseList.get(v).getEquipmentTypeRise())){
                                String riseNumber = "";
                                if(v < 10){
                                    riseNumber = "0"+ v;
                                }else{
                                    riseNumber =v+"";
                                }
                                if(j < 10){
                                    typeTrails.setEquipmentTypeTrailsPosition(riseNumber+"0"+j);
                                }else{
                                    typeTrails.setEquipmentTypeTrailsPosition(riseNumber+j);
                                }
                            }
                            equipmentTypeTrailsList.add(typeTrails);
                        }
                        int x = equipmentTypeTrailsMapper.insertBatchTrails(equipmentTypeTrailsList);
                    }
                }
                return Msg.success();
            }
        }
        return Msg.fail();
    }

    @Override
    public Msg editEquipmentTypeTrails(EquipmentTypeTrails equipmentTypeTrails) {
        int i = equipmentTypeTrailsMapper.updateByPrimaryKeySelective(equipmentTypeTrails);
        if(i > 0){
            return Msg.success();
        }
        return Msg.fail();
    }


    /**
     * 根据设别类型修改设备货道信息
     * @param equipmentId
     * @param equipmentTypeId
     * @return
     */
    @Override
    public Msg updateEquipmentByType(String equipmentId, Integer equipmentTypeId){

        if (ToolUtil.isNotEmpty(equipmentId) && ToolUtil.isNotEmpty(equipmentTypeId)) {
            //机箱
            EquipmentTypeCase equipmentTypeCase = new EquipmentTypeCase();
            equipmentTypeCase.setEquipmentTypeId(equipmentTypeId);
            List<EquipmentTypeCase> typeCaseList = equipmentTypeCaseMapper.selectByExampleSelective(equipmentTypeCase);
            //层
            EquipmentTypeRise equipmentTypeRise = new EquipmentTypeRise();
            equipmentTypeRise.setEquipmentTypeId(equipmentTypeId);
            List<EquipmentTypeRise> typeRiseList = equipmentTypeRiseMapper.selectByExampleSelective(equipmentTypeRise);
            //货道
           EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
           typeTrails.setEquipmentTypeId(equipmentTypeId);
            List<EquipmentTypeTrails> equipmentTypeTrailsList = equipmentTypeTrailsMapper.selectByExampleSelective(typeTrails);
            List<Trails> trailsList = new ArrayList<>();
            if(ToolUtil.isNotEmpty(equipmentTypeTrailsList) && equipmentTypeTrailsList.size() > 0){
                for(EquipmentTypeTrails equipmentTypeTrails:equipmentTypeTrailsList){
                    Trails trails = new Trails();
                    trails.setTrailsEquipmentId(equipmentId);
                    trails.setTrailsNumber(equipmentTypeTrails.getEquipmentTypeTrailsNumber());
                    if(ToolUtil.isEmpty(equipmentTypeTrails.getEquipmentTypeTrailsCapacity())){
                        trails.setTrailsGoodsCapacity(null);
                    }else {
                        trails.setTrailsGoodsCapacity(equipmentTypeTrails.getEquipmentTypeTrailsCapacity());
                    }
                    if(ToolUtil.isEmpty(equipmentTypeTrails.getEquipmentTypeTrailsType())){
                        trails.setTrailsType(null);
                    }else{
                        trails.setTrailsType(equipmentTypeTrails.getEquipmentTypeTrailsType());
                    }
                    for(EquipmentTypeCase typeCase:typeCaseList){
                        if(equipmentTypeTrails.getEquipmentTypeCaseId().equals(typeCase.getEquipmentCaseId())){
                            trails.setTrailsCaseId(typeCase.getEquipmentCaseNumber());
                            break;
                        }
                    }
                    for(EquipmentTypeRise typeRise:typeRiseList){
                        if(equipmentTypeTrails.getEquipmentTypeTrailsRise().equals(typeRise.getEquipmentTypeRiseId())){
                            trails.setTrailsRiseId(Integer.parseInt(typeRise.getEquipmentTypeRise()));
                            break;
                        }
                    }
                    trails.setTrailsPosition(equipmentTypeTrails.getEquipmentTypeTrailsPosition());
                    trailsList.add(trails);
                }
            }
            Trails t = new Trails();
            t.setTrailsEquipmentId(equipmentId);
            List<Trails> list = trailsMapper.selectByExample(t);
            if(ToolUtil.isNotEmpty(list) && list.size() > 0){
                int i = trailsMapper.deleteByEquipmentId(equipmentId);
                if(i > 0){
                    trailsMapper.insertBatchTrails(trailsList);
                }
            }else{
                trailsMapper.insertBatchTrails(trailsList);
            }
            //修改设备类型
            Equipment equipment = new Equipment();
            equipment.setEquipmentId(equipmentId);
            equipment.setEquipmentType(equipmentTypeId.toString());
            this.equipmentMapper.updateByPrimaryKeySelective(equipment);

            return Msg.success();
        }else {
            return Msg.fail();
        }
    }

    @Override
    public Msg editEquipmentTypeRise(EquipmentTypeRise equipmentTypeRise) {
        int i = equipmentTypeRiseMapper.updateByPrimaryKeySelective(equipmentTypeRise);
        if(i > 0){
            EquipmentTypeTrails equipmentTypeTrails = new EquipmentTypeTrails();
            equipmentTypeTrails.setEquipmentTypeTrailsRise(equipmentTypeRise.getEquipmentTypeRiseId());
            //equipmentTypeTrails.setEquipmentTypeId(equipmentTypeRise.getEquipmentTypeId());
            List<EquipmentTypeTrails> typeTrailsList = equipmentTypeTrailsMapper.selectByExampleSelective(equipmentTypeTrails);
            if (equipmentTypeRise.getEquipmentTypeRiseTrails().equals(typeTrailsList.size())){
                EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
                typeTrails.setEquipmentTypeTrailsRise(equipmentTypeRise.getEquipmentTypeRiseId());
                typeTrails.setEquipmentTypeTrailsCapacity(equipmentTypeRise.getEquipmentTypeRiseCapacity());
                typeTrails.setEquipmentTypeTrailsType(equipmentTypeRise.getEquipmentTypeRiseType());
                int result = equipmentTypeTrailsMapper.updateByRiseId(typeTrails);
                if(result > 0){
                    return Msg.success();
                }
            }else{
                List<EquipmentTypeTrails> equipmentTypeTrailsList = new ArrayList<>();
                int x = equipmentTypeTrailsMapper.deleteTrailsByRiseId(equipmentTypeRise.getEquipmentTypeRiseId());
                for(int y = 0; y < equipmentTypeRise.getEquipmentTypeRiseTrails();y++){
                    EquipmentTypeTrails typeTrails = new EquipmentTypeTrails();
                    Integer t = y+1;
                    String s = equipmentTypeRise.getEquipmentTypeRise();
                    String s1 = "";
                    Integer integer = null;
                    if(s.substring(0,1).equals("0")){
                        s1 = s.substring(1);
                        integer = Integer.parseInt(s.substring(1)) - 1;
                    }else{
                        s1 = s;
                        integer = Integer.parseInt(s);
                    }
                    typeTrails.setEquipmentTypeTrailsNumber(s1 +"-"+ t);
                    typeTrails.setEquipmentTypeTrailsCapacity(equipmentTypeRise.getEquipmentTypeRiseCapacity());
                    typeTrails.setEquipmentTypeTrailsType(equipmentTypeRise.getEquipmentTypeRiseType());
                    String p = "";
                    if( y < 10){
                        p = "0"+y;
                    }else {
                        p = y+ "";
                    }
                    String p1 = "";
                    if (integer < 10){
                        p1 = "0"+integer;
                    }else{
                        p1 = integer+"";
                    }
                    typeTrails.setEquipmentTypeTrailsPosition(p1 + p);
                    typeTrails.setEquipmentTypeTrailsRise(equipmentTypeRise.getEquipmentTypeRiseId());
                    typeTrails.setEquipmentTypeCaseId(equipmentTypeRise.getEquipmentTypeCaseId());
                    typeTrails.setEquipmentTypeId(equipmentTypeRise.getEquipmentTypeId());
                    typeTrails.setEquipmentTypeCaseId(equipmentTypeRise.getEquipmentTypeCaseId());
                    typeTrails.setEquipmentTypeId(equipmentTypeRise.getEquipmentTypeId());
                    equipmentTypeTrailsList.add(typeTrails);
                }
                equipmentTypeTrailsMapper.insertBatchTrails(equipmentTypeTrailsList);
            }
            return Msg.success();
        }
        return Msg.fail();
    }

    @Override
    public Msg deleteEquipmentTypeRise(String equipmentTypeIds) {
        String[] strs = equipmentTypeIds.split(",");
        for(int j = 0;j < strs.length;j++){
            int i = equipmentTypeMapper.deleteByPrimaryKey(Integer.parseInt(strs[j]));
            if(i > 0){
                EquipmentTypeCase typeCase = new EquipmentTypeCase();
                typeCase.setEquipmentTypeId(Integer.parseInt(strs[j]));
                //List<EquipmentTypeCase> typeCaseList = equipmentTypeCaseMapper.selectByExampleSelective(typeCase);
                equipmentTypeCaseMapper.deleteCaseByTypeId(Integer.parseInt(strs[j]));
                equipmentTypeRiseMapper.deleteRiseByTypeId(Integer.parseInt(strs[j]));
                equipmentTypeTrailsMapper.deleteTrailsByTypeId(Integer.parseInt(strs[j]));
                //equipmentTypeTrailsMapper.deleteTrailsByCaseId(caseList);
            }
        }
       return Msg.success();
    }

    @Override
    public Msg deleteEquipmentCase(String equipmentTypeCaseIds) {
        String[] strs = equipmentTypeCaseIds.split("-");
        for(int i = 0;i < strs.length;i++){
            int result = equipmentTypeCaseMapper.deleteByPrimaryKey(Integer.parseInt(strs[i]));
            if(result > 0){
                equipmentTypeRiseMapper.deleteRiseByCaseId(Integer.parseInt(strs[i]));
                equipmentTypeTrailsMapper.deleteTrailsByCaseId(Integer.parseInt(strs[i]));
            }
        }
        return Msg.success();
    }


    /**
     * 查询设备的货道数量（Android）
     * @param equipmentId
     * @return
     */
    public Msg selectEquipmentTypeByEquipment(String equipmentId) {

        if (ToolUtil.isNotEmpty(equipmentId)) {

            List<EquipmentTypeRiseVO> equipmentTypeRiseVOS = new ArrayList<EquipmentTypeRiseVO>();

            //查询设备信息
            Equipment equipment = new Equipment();
            equipment.setEquipmentId(equipmentId);
            Equipment selectEquipment = this.equipmentMapper.selectByPrimary(equipment);

            if (ToolUtil.isNotEmpty(selectEquipment)) {
                //查询设备类型的层信息
                EquipmentTypeRise equipmentTypeRise = new EquipmentTypeRise();
                //equipmentTypeRise.setEquipmentTypeId(Integer.parseInt(selectEquipment.getEquipmentType()));
                List<EquipmentTypeRise> equipmentTypeRises= this.equipmentTypeRiseMapper.selectByExampleSelective(equipmentTypeRise);
                if (ToolUtil.isNotEmpty(equipmentTypeRises)) {
                    for (EquipmentTypeRise forEquipmentTypeRise:equipmentTypeRises) {
                        //保存要返回的信息
                        EquipmentTypeRiseVO equipmentTypeRiseVO = new EquipmentTypeRiseVO();
                        equipmentTypeRiseVO.setEquipmentTypeRise(forEquipmentTypeRise.getEquipmentTypeRise());
                        equipmentTypeRiseVO.setEquipmentTypeRiseTrails(forEquipmentTypeRise.getEquipmentTypeRiseTrails());
                        //equipmentTypeRiseVO.setEquipmentTypeTrailsCapacity(forEquipmentTypeRise.getEquipmentTypeTrailsCapacity());

                        equipmentTypeRiseVOS.add(equipmentTypeRiseVO);
                    }
                }
            }

            return Msg.success().add("equipmentTypeRise", equipmentTypeRiseVOS);
        }else {
            return Msg.fail().add("msg", "设备id为空!!");
        }
    }

    @Override
    public int insertEquipmentType(EquipmentType equipmentType) {
        return equipmentTypeMapper.insertEquipmentType(equipmentType);
    }





}
